// 接口类
interface IPerson {
    name: string
    age: number
    sayHi(name: string): void
}

let person: IPerson = {
    name: 'black',
    age: 25,
    sayHi(name) {
        console.log('sieg heil');
    }
}


// 接口类型与类型别名
// 相同点：都可以为对象指定类型
// 不同点：类型别名可以为任何类型指定别名，接口只能为对象指定类型
// Black只能是对象的
interface Black {
    name: string
    age: number
    sayHi(name: string): void
}
// White可以是多个类型的
type White = {
    name: string
    age: number
    sayHi(name: string): void
}
type NumStr = number | string

let person11: Black = {
    name: 'black',
    age: 25,
    sayHi(name) {
        console.log('hello' + name);
    }
}
let person22: White = {
    name: 'black',
    age: 25,
    sayHi(name) {
        console.log('hello' + name);
    }
}

// 接口继承 extends
// interface 新接口 extends 旧接口
interface Black11 extends Black {
    idol: string
}

let person33: Black11 = {
    name: 'black',
    age: 25,
    idol: 'Adolf Hitler',
    sayHi(name) {
        console.log('hello' + name);
    }
}
